<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>
<?
require_once($_SERVER['DOCUMENT_ROOT']."/bitrix/modules/main/install/wizard_sol/wizard.php");

class SelectSiteStep extends CSelectSiteWizardStep
{
    function InitStep()
    {
        parent::InitStep();

        $wizard =& $this->GetWizard();
        $wizard->solutionName = "lombard";

        $wizard->SetVar("templateID", "lombard");

        $this->SetNextStep("site_settings");
    }
}

/*class SelectTemplateStep extends CSelectTemplateWizardStep
{
    function InitStep()
    {
        $this->SetStepID("select_template");
        $this->SetTitle(GetMessage("SELECT_TEMPLATE_TITLE"));
        $this->SetSubTitle(GetMessage("SELECT_TEMPLATE_SUBTITLE"));
        //$this->SetPrevStep("welcome_step");
        $this->SetNextStep("site_settings");
        $this->SetNextCaption(GetMessage("NEXT_BUTTON"));
    }

    function OnPostForm()
    {
        $wizard =& $this->GetWizard();

        $proactive = COption::GetOptionString("statistic", "DEFENCE_ON", "N");
        if ($proactive == "Y")
        {
            COption::SetOptionString("statistic", "DEFENCE_ON", "N");
            $wizard->SetVar("proactive", "Y");
        }
        else
        {
            $wizard->SetVar("proactive", "N");
        }

        if ($wizard->IsNextButtonClick())
        {
            $arTemplates = array("ishop_blue_green");

            $templateID = $wizard->GetVar("wizTemplateID");

            if (!in_array($templateID, $arTemplates))
                $this->SetError(GetMessage("wiz_template"));

        }
    }

    function ShowStep()
    {
        $wizard =& $this->GetWizard();

        $arTemplateOrder = array("ishop_blue_green");

        $defaultTemplateID = COption::GetOptionString("main", "wizard_template_id", "ishop_blue_green", $wizard->GetVar("siteID"));
        if (!in_array($defaultTemplateID, array("ishop_blue_green"))) $defaultTemplateID = "ishop_blue_green";
        $wizard->SetDefaultVar("wizTemplateID", $defaultTemplateID);

        $arTemplateInfo = array(
            "ishop_blue_green" => array(
                "NAME" => GetMessage("WIZ_TEMPLATE_NAME"),
                "DESCRIPTION" => GetMessage("WIZ_TEMPLATE_DESCRIPTION"),
                "PREVIEW" => $wizard->GetPath()."/site/templates/ishop/lang/".LANGUAGE_ID."/preview_blue_green.png",
                "SCREENSHOT" => $wizard->GetPath()."/site/templates/ishop/lang/".LANGUAGE_ID."/screen_blue_green.png",
            ),
        );

        $wizard->SetVar("templateID", "ishop");
        $this->content .= "<input type='hidden' value='ishop' name='templateID' id='templateID'>";

        $this->content .= '<table width="100%" cellspacing="4" cellpadding="8">';
        foreach ($arTemplateOrder as $templateID)
        {
            $arTemplate = $arTemplateInfo[$templateID];

            if (!$arTemplate)
                continue;

            $this->content .= "<tr>";
            $this->content .= '<td width="25">'.$this->ShowRadioField("wizTemplateID", $templateID, Array("id" => $templateID))."</td>";

            if ($arTemplate["SCREENSHOT"] && $arTemplate["PREVIEW"])
                $this->content .= '<td width="160" valign="top">'.CFile::Show2Images($arTemplate["PREVIEW"], $arTemplate["SCREENSHOT"], 150, 150, ' border="0"')."</td>";
            else
                $this->content .= '<td width="160" valign="top">'.CFile::ShowImage($arTemplate["SCREENSHOT"], 150, 150, ' border="0"', "", true)."</td>";

            $this->content .= '<td valign="top"><label for="'.$templateID.'"><b>'.$arTemplate["NAME"]."</b><p>".$arTemplate["DESCRIPTION"]."</p></label></td>";

            $this->content .= "</tr>";
            $this->content .= "<tr><td><br /></td></tr>";
        }

        $this->content .= "</table>";
    }
}

class SelectThemeStep extends CSelectThemeWizardStep
{

}*/

class SiteSettingsStep extends CSiteSettingsWizardStep
{
    function InitStep()
    {
        $wizard =& $this->GetWizard();
        $wizard->solutionName = "lombard";
        parent::InitStep();

        $this->SetNextCaption(GetMessage("NEXT_BUTTON"));
        $this->SetTitle(GetMessage("WIZ_STEP_SITE_SET"));

        $siteID = $wizard->GetVar("siteID");

        /*if(COption::GetOptionString("lombard", "wizard_installed", "N", $siteID) == "Y" && !WIZARD_INSTALL_DEMO_DATA)
            $this->SetNextStep("data_install");
        else
        {
            if(LANGUAGE_ID != "ru")
                $this->SetNextStep("pay_system");
            else
                $this->SetNextStep("shop_settings");
        }*/

        $templateID = $wizard->GetVar("templateID");
        if(!$templateID)
        {
            $wizard->SetVar("templateID", "lombard");
        }


        $wizard->SetDefaultVars(Array("siteNameSet" => true));

        $wizard->SetDefaultVars(
            Array(
                "siteName" => $this->GetFileContent(WIZARD_SITE_PATH."include/description.php", GetMessage("WIZ_COMPANY_NAME_DEF")),
                "siteTelephone" => $this->GetFileContent(WIZARD_SITE_PATH."include/phones.php", GetMessage("WIZ_COMPANY_TELEPHONE_DEF")),
                "siteCopy" => $this->GetFileContent(WIZARD_SITE_PATH."include/copyright.php", GetMessage("WIZ_COMPANY_COPY_DEF")),
                "shopEmail" => COption::GetOptionString("ishop", "shopEmail", "sale@".$_SERVER["SERVER_NAME"], $siteID),



                "siteMetaDescription" => GetMessage("wiz_site_desc"),
                "siteMetaKeywords" => GetMessage("wiz_keywords"),
            )
        );

    }

    function ShowStep()
    {
        $wizard =& $this->GetWizard();

        $this->content .= '<div class="wizard-input-form">';
        if($wizard->GetVar('siteNameSet', true)){
            $this->content .= '
			<div class="wizard-input-form-block">
				<h4><label for="siteName">'.GetMessage("WIZ_COMPANY_NAME").'</label></h4>
				<div class="wizard-input-form-block-content">
					<div class="wizard-input-form-field wizard-input-form-field-text">'.$this->ShowInputField('text', 'siteName', array("id" => "siteName")).'</div>
				</div>
			</div>';
        }

        if($wizard->GetVar('siteLogoSet', true)){
            $siteLogo = $wizard->GetVar("siteLogo", true);

            $this->content .= '
			<div class="wizard-input-form-block">
				<h4><label for="siteName">'.GetMessage("WIZ_COMPANY_LOGO").'</label></h4>
				<div class="wizard-input-form-block-content">
					<div class="wizard-input-form-field wizard-input-form-field-text">'.CFile::ShowImage($siteLogo, 280, 40, "border=0 vspace=15") . '<br>' . $this->ShowFileField("siteLogo", Array("show_file_info" => "N", "id" => "siteLogo")).'</div>
				</div>
			</div>';
        }

        $this->content .= '
		<div class="wizard-input-form-block">
			<h4><label for="siteTelephone">'.GetMessage("WIZ_COMPANY_TELEPHONE").'</label></h4>
			<div class="wizard-input-form-block-content">
				<div class="wizard-input-form-field wizard-input-form-field-text">'.$this->ShowInputField('text', 'siteTelephone', array("id" => "siteTelephone")).'</div>
			</div>
		</div>';

        $this->content .= '
		<div class="wizard-input-form-block">
			<h4><label for="siteCopy">'.GetMessage("WIZ_COMPANY_COPY").'</label></h4>
			<div class="wizard-input-form-block-content">
				<div class="wizard-input-form-field wizard-input-form-field-textarea">'.$this->ShowInputField('textarea', 'siteCopy', array("rows"=>"3", "id" => "siteCopy")).'</div>
			</div>
		</div>';

        /*$this->content .= '
		<div class="wizard-input-form-block">
			<h4><label for="shopEmail">'.GetMessage("WIZ_COMPANY_EMAIL").'</label></h4>
			<div class="wizard-input-form-block-content">
				<div class="wizard-input-form-field wizard-input-form-field-textarea">'.$this->ShowInputField('textarea', 'shopEmail', array("id" => "shopEmail")).'</div>
			</div>
		</div>';*/


        $firstStep = COption::GetOptionString("main", "wizard_first" . substr($wizard->GetID(), 7)  . "_" . $wizard->GetVar("siteID"), false, $wizard->GetVar("siteID"));
        $styleMeta = 'style="display:block"';
        //if($firstStep == "Y") $styleMeta = 'style="display:none"';

        $this->content .= '
		<div  id="bx_metadata" '.$styleMeta.'>
			<div class="wizard-input-form-block">
				<h4 style="margin-top:0"><label for="siteMetaDescription">'.GetMessage("wiz_meta_data").'</label></h4>
				<label for="siteMetaDescription">'.GetMessage("wiz_meta_description").'</label>
				<div class="wizard-input-form-block-content" style="margin-top:7px;">
					<div class="wizard-input-form-field wizard-input-form-field-textarea">'.
            $this->ShowInputField("textarea", "siteMetaDescription", Array("id" => "siteMetaDescription", "style" => "width:100%", "rows"=>"3")).'</div>
				</div>
			</div>';
        $this->content .= '
			<div class="wizard-input-form-block">
				<label for="siteMetaKeywords">'.GetMessage("wiz_meta_keywords").'</label><br>
				<div class="wizard-input-form-block-content" style="margin-top:7px;">
					<div class="wizard-input-form-field wizard-input-form-field-text">'.
            $this->ShowInputField('text', 'siteMetaKeywords', array("id" => "siteMetaKeywords")).'</div>
				</div>
			</div>
		</div>';

//install Demo data
        /*if($firstStep == "Y")
        {
            $this->content .= '
			<div class="wizard-input-form-block">
				<div class="wizard-input-form-block-content">'.
                $this->ShowCheckboxField(
                    "installDemoData",
                    "Y",
                    (array("id" => "installDemoData", "onClick" => "if(this.checked == true){document.getElementById('bx_metadata').style.display='block';}else{document.getElementById('bx_metadata').style.display='none';}"))
                ).
                '
                <label for="installDemoData">'.GetMessage("wiz_structure_data").'</label>
				</div>
			</div>';
        }
        else*/
        {
            $this->content .= $this->ShowHiddenField("installDemoData","Y");
        }

        /*if(LANGUAGE_ID != "ru")
        {
            CModule::IncludeModule("catalog");
            $db_res = CCatalogGroup::GetGroupsList(array("CATALOG_GROUP_ID"=>'1', "BUY"=>"Y", "GROUP_ID"=>2));
            if (!$db_res->Fetch())
            {
                $this->content .= '
				<div class="wizard-input-form-block">
					<h4><label for="shopAdr">'.GetMessage("WIZ_SHOP_PRICE_BASE_TITLE").'</label></h4>
					<div class="wizard-input-form-block-content">
						'. GetMessage("WIZ_SHOP_PRICE_BASE_TEXT1") .'<br><br>
						'. $this->ShowCheckboxField("installPriceBASE", "Y",
                        (array("id" => "install-demo-data")))
                    . ' <label for="install-demo-data">'.GetMessage("WIZ_SHOP_PRICE_BASE_TEXT2").'</label><br />

					</div>
				</div>';
            }
        }*/

        $this->content .= '</div>';
    }
    function OnPostForm()
    {
        $wizard =& $this->GetWizard();

        //set site name
        COption::SetOptionString("main", "site_name", $wizard->GetVar("siteName"));
        $arFields = Array("NAME" => $wizard->GetVar("siteName"));
        $obSite = new CSite;
        $siteRes = $obSite->Update($wizard->GetVar("siteID"), $arFields);

        $res = $this->SaveFile("siteLogo", Array("extensions" => "gif,jpg,jpeg,png", "max_height" => 40, "max_width" => 280, "make_preview" => "Y"));
    }
}

class DataInstallStep extends CDataInstallWizardStep
{
    function CorrectServices(&$arServices)
    {
        $wizard =& $this->GetWizard();
        if($wizard->GetVar("installDemoData") != "Y")
        {
        }
    }
}

class FinishStep extends CFinishWizardStep
{
}
?>